package com.yusys.jin.blog;


import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import com.yusys.jin.blog.entity.GameRole;
import com.yusys.jin.blog.entity.MailCode;
import com.yusys.jin.blog.entity.Picture;
import com.yusys.jin.blog.entity.User;
import com.yusys.jin.blog.mapper.GameRoleMapper;
import com.yusys.jin.blog.mapper.MailCodeMapper;
import com.yusys.jin.blog.mapper.UserMapper;

@RunWith(SpringRunner.class)
@SpringBootTest
public class mapperTestCase {
    @Autowired
    UserMapper mapper;
    @Autowired
    MailCodeMapper MailMapper;
    @Autowired
    GameRoleMapper GameRoleMapper;

    @Test
    public void insert() {

        User user = new User();
        user.setUserName("罗少校");
        user.setNickName("班长");
        user.setPassWord("821221");
        Integer i = mapper.insert(user);
        System.err.println(i);

    }

    @Test
    public void select() {
        User u = mapper.findUserByid("23");
        System.err.println(u);
        /*
         * User u = mapper.findByUsername("罗少校"); System.err.println(u);
         */
    }

    @Test
    public void mailtest() {
        /*
         * MailCode m = new MailCode(); m.setEmail("110680320@qq.com");
         * m.setMailcode("2123"); m.setSessionid("2121");
         *
         * MailMapper.insert(m);
         */
    }

    @Test
    public void find() {
        Picture p = new Picture();
        p = mapper.findAvatar(1, 26);
        System.err.println(p);



        /*
         * MailCode m = MailMapper.findSessionByid("2121"); System.err.println(m);
         */
    }

    @Test
    public void delete() {
        /* MailMapper.delete("2121"); */
    }

    @Test
    public void insertpicture() {
        Picture p = new Picture();
        p.setPicturename("sssssss");
        p.setUid(23);

        p.setCreatedUser("sasas");

        mapper.insertAvatar(p);
    }

    @Test
    public void insertRole() {
        GameRole role = new GameRole();
        role.setUid(3);
        role.setCamp("Horde");
        role.setGuild("绘梦之约");
        role.setLevel(120);
        role.setCareer("牧师");
        role.setLevelInGuild("中流砥柱");
        role.setRoleName("蔡徐坤");
        Integer rows = GameRoleMapper.insertGameRole(role);
        System.err.println(rows);
    }

    @Test
    public void queryRoles() {
        List<GameRole> list = GameRoleMapper.queryRoles(3);
        for (GameRole role : list) {
            System.err.println(role);
        }
    }

    @Test
    public void queryRole() {
        GameRole role = GameRoleMapper.queryRoleByNameAndServerCD("图拉糖", "158");
        System.err.println(role);
    }
}











